import { createRouter, createWebHistory } from 'vue-router'
import login from '../views/login.vue'
import home from '../views/home.vue'
import c404 from '../views/c404.vue'

const routes = [
  {
    path: '/',
    name: 'login',
    component: login,
    meta:{
      requiresAuth:false,//是否需要登录访问，  true需要
      name:'登录页A'
    },
  },
  {
    path: '/home',
    name: 'home',
    component: home,
    meta:{
      requiresAuth:true,//登录后才可进入
      name:'首页A'
    },
  },
  {
    path: '/404',
    name: '404',
    component: c404,
    meta:{
      requiresAuth:false,//不需要
      name:'404A'
    },
  }
]
//动态路由
export const DynamicRouter = [
  {
    path: '/',
    component: login,
    name: 'container',
    redirect:'home',
    meta:{
      requiresAuth:true,//登录后才可进入
      name:'首页B'
    },
    childrenn: [
      {
        path:'home',
        name: 'home',
        meta:{
          requiresAuth:true,//登录后才可进入
          name:'首页B',
          icon:'icon-name'
        },
      }
    ]
  },
  {
    path: '/404',
    component: c404,
    hidden: true
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
